package com.huobao.yunying.adapters;

import java.util.List;

import com.huobao.yunying.entity.KetangGrid;
import com.huobao.yunying.utils.ImageUtils;
import com.huobao.yunying.utils.ImageUtils.OnImageLoadListener;
import com.huobao.zhangying.R;
import com.xrz.sxm.base.utils.ScreenUtil;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;

public class Adapter_ketang_GridView extends QuickAdapter<KetangGrid> {

public Adapter_ketang_GridView(Context context, List<KetangGrid> data) {
		super(context, R.layout.item_ketang_grid, data);
		// TODO Auto-generated constructor stub
	}

//	public Adapter_ketang_GridView(Context context) {
//		super(context, R.layout.item_ketang_grid);
//	}

	@Override
	protected void convert(BaseAdapterHelper arg0, KetangGrid arg1) {
		arg0.setText(R.id.tv_text, arg1.getCourse_title());
		final ImageView imageView = arg0.getView(R.id.imageview);
		ImageUtils.loadimg(imageView, arg1.getCourse_img(), new OnImageLoadListener() {

			@Override
			public void onLoadSuccess(Drawable drawable) {
				int newWidth = ScreenUtil.getInstant().getDisWidth(context) / 2 - 20;
				int newHight = newWidth * drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth();
				LayoutParams params = (LayoutParams) imageView.getLayoutParams();
				params.width = newWidth;
				params.height = newHight;
				imageView.setLayoutParams(params);
			}
		});
	}

}
